package com.wisn.appcheckmethod.plugin.hook;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;

public class MethodSettle extends XC_MethodHook {
    private final String processName;
    private final String packageName;
    private final String TAG;

    public MethodSettle(String processName, String packageName,String tag) {
        this.TAG = tag;
        this.processName = processName;
        this.packageName = packageName;
    }

    @Override
    protected void beforeHookedMethod(MethodHookParam param) {
//        XposedBridge.log(TAG+"[" + packageName + "][" + processName + "]" + param.method.getName() + "()"+printLog(param));
    }


    @Override
    protected void afterHookedMethod(MethodHookParam param) {
        StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("---------------"+TAG+" start----------------\n");
        stringBuilder.append("[" + packageName + "][" + processName + "]" + param.method.getName() + "(),参数：");
        Object[] args = param.args;
        for (Object ob : args) {
            stringBuilder.append(","+ ob);
        }
        stringBuilder.append(" result:"+ param.getResult());
        stringBuilder.append("\n");
        for (StackTraceElement temp : stackTraceElements) {
            stringBuilder.append(temp.toString() + "\n");
        }
        stringBuilder.append("---------------over----------------\n");
        XposedBridge.log(stringBuilder.toString());
    }
}
